<?php
/**
 * Created by PhpStorm.
 * User: ye
 * Date: 2017/11/17
 * Time: 下午8:36
 */

namespace App\Third;


use App\CustomMsgReceive;
use GuzzleHttp\Client;

class Gitee {
    private $assessToken;

    public function __construct() {
        $this->assessToken = new AccessToken(config('gitee.client_id'), config('gitee.client_Secret'));
    }

    public function createIssue($title, $content) {
        $client = new Client();
        $data = [
            'form_params' => [
                'title' => $title,
                'body' => $content,
                'access_token' => $this->assessToken->getGiteeAccessToken()
            ]
        ];
        $response = $client->post(config('gitee.issues_url'), $data);

        return json_decode((string)$response->getBody());
    }

    public function createComments($number, $content) {
        $client = new Client();
        $data = [
            'form_params' => [
                'body' => $content,
                'access_token' => $this->assessToken->getGiteeAccessToken()
            ]
        ];
        $response = $client->post(config('gitee.issues_url')."/$number/comments", $data);

        return json_decode((string)$response->getBody());
    }

    /**
     * 获取评论 —— 相当于 回答用户问题
     */
    public function receiveNote($note, $noteable_id, $per_iid) {


    }
}